package com.woniuxy.userassembly.apiimpl;


import com.woniuxy.api.RbacUserRoleApi;
import com.woniuxy.common.Result;
import com.woniuxy.form.RbacUserRoleForm;
import com.woniuxy.userassembly.model.RbacUserRole;
import com.woniuxy.userassembly.service.IRbacUserRoleService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Liyfi
 * @since 2021-05-22
 */
@RestController
public class RbacUserRoleController implements RbacUserRoleApi {
    @Autowired
    private IRbacUserRoleService service;

    @Override
    public Result userAddedRole(RbacUserRoleForm form) {
        RbacUserRole userRole = new RbacUserRole();
        BeanUtils.copyProperties(form,userRole);
        int i = service.addUserRole(userRole);
        if(i == 1){
            return Result.success("用户授予角色成功");
        }
        return Result.fail("失败");
    }
}

